package com.cell.api.application.netty.client;

import com.cell.api.application.netty.code.Packet;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.extern.slf4j.Slf4j;

/**
 * <p>
 * 客户端handler
 * </p>
 *
 * @author zdy
 * @date 2021/11/8
 */
@Slf4j
public class SimpleClientHandler extends ChannelInboundHandlerAdapter {

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        log.info("客户端收到消息: {}", msg.toString());
        Packet packet = (Packet) msg;
        String str = new String(packet.getBytes());
        log.info("客户端收到消息内容: {}", str);
        ctx.flush();
    }
}
